package com.xhc.demo.dto;

import com.xhc.demo.entity.Photo;
import com.xhc.demo.utils.Utils;
import java.math.BigDecimal;
import java.time.LocalDateTime;

public class PhotoDTO {
    private Long photoId;
    private String imageUrl;
    private String thumbnailUrl;
    private String videoUrl;
    private String material;
    private String nfcQrcode;
    private String resolution;
    private String size;
    private BigDecimal amount;
    private LocalDateTime createTime;

    public static PhotoDTO fromEntity(Photo photo) {
        if (photo == null) {
            return null;
        }
        PhotoDTO dto = new PhotoDTO();
        dto.setPhotoId(photo.getPhotoId());
        // 使用七牛云私有空间下载链接
        dto.setImageUrl(Utils.getQiniuPrivateDownloadUrlThumbil(photo.getImageUrl()));
        dto.setThumbnailUrl(Utils.getQiniuPrivateDownloadUrlThumbil(photo.getThumbnailUrl()));
        dto.setVideoUrl(photo.getVideoUrl() != null ? Utils.getQiniuVideoThumbil(photo.getVideoUrl()) : null);
        dto.setMaterial(photo.getMaterial());
        dto.setNfcQrcode(photo.getNfcQrcode());
        dto.setResolution(photo.getResolution());
        dto.setSize(photo.getSize());
        dto.setAmount(photo.getAmount());
        dto.setCreateTime(photo.getCreateTime());
        return dto;
    }

    // Getters and Setters
    public Long getPhotoId() {
        return photoId;
    }

    public void setPhotoId(Long photoId) {
        this.photoId = photoId;
    }

    public String getImageUrl() {
        return imageUrl;
    }

    public void setImageUrl(String imageUrl) {
        this.imageUrl = imageUrl;
    }

    public String getThumbnailUrl() {
        return thumbnailUrl;
    }

    public void setThumbnailUrl(String thumbnailUrl) {
        this.thumbnailUrl = thumbnailUrl;
    }

    public String getVideoUrl() {
        return videoUrl;
    }

    public void setVideoUrl(String videoUrl) {
        this.videoUrl = videoUrl;
    }

    public String getMaterial() {
        return material;
    }

    public void setMaterial(String material) {
        this.material = material;
    }

    public String getNfcQrcode() {
        return nfcQrcode;
    }

    public void setNfcQrcode(String nfcQrcode) {
        this.nfcQrcode = nfcQrcode;
    }

    public String getResolution() {
        return resolution;
    }

    public void setResolution(String resolution) {
        this.resolution = resolution;
    }

    public String getSize() {
        return size;
    }

    public void setSize(String size) {
        this.size = size;
    }

    public BigDecimal getAmount() {
        return amount;
    }

    public void setAmount(BigDecimal amount) {
        this.amount = amount;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }
}
